package com.njbdqn.ALi.zjg.dao;

import java.util.List;

import org.njbdqn.ali.database.SqlTemplate;

import com.njbdqn.ALi.zjg.entity.Comment;
import com.njbdqn.ALi.zjg.vo.SubcommentsVO;

public class SubcommentDAO {
	private SqlTemplate template;
	
	public SubcommentDAO(){
		template = new SqlTemplate();
	}
	public int save(Comment comment){
		String sql="insert into comment (account,book_id,replyid,commentcontent, "
				+ " commenttime,great,commentnumber) values (?,?,?,?,?,?,?)";
		return template.update(sql, new Object[]{comment.getAccount(),comment.getBook_id(),
				comment.getReplyid(),comment.getCommentcontent(),comment.getCommenttime()});
	}
	
	public List findAll(int book_id,int replyid){	
		String sql="select u.nickname,c.commentcontent,c.commenttime from comment c ,"
				+ " userinfos u where replyid = ? and book_id=?";
		return template.resultToArray(sql, new Object[]{book_id,replyid}, SubcommentsVO.class);
	}
	
}
